<%--
  Created by IntelliJ IDEA.
  User: 金刚天使葫芦娃
  Date: 2017/9/13
  Time: 20:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="js/util/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="js/util/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="js/util/easyui/demo/demo.css">
    <script type="text/javascript" src="js/util/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="js/util/easyui/jquery.easyui.min.js"></script>

</head>
<body>
<form name="loginform" method="post" action="User/Login">
    <div style="margin:20px 0;"></div>
    <div class="easyui-panel" title="My12306购票系统--用户登录" style="width:600px">
        <div style="padding:10px 60px 20px 60px">
            <table>
                <tr>
                    <table>
                        <tr>
                            <td>用户名：</td>
                            <td><input class="easyui-textbox" data-options="required:true" validType="loginname"
                                       id="loginname" name="loginname"></td>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td>密&nbsp;&nbsp;码：</td>
                            <td><input class="easyui-passwordbox" data-options="required:true" validType="password"
                                       id="password" name="password"></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td>验&nbsp;证&nbsp;码：</td>
                            <td><input type="text" name="codein" class="easyui-textbox" data-options="required:true">
                            </td>
                            <td><img src="User/ValidateCode" id="codeimage"></td>
                            <td><input type="button" onclick="javascript:reloadcode()" value="刷新"></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td><input type="submit" value="登录">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
                                    type="reset" value="重置"></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <%
                                    String msg = (String) request.getAttribute("msg");
                                    if (msg != null) {
                                %>
                                <%= msg %>
                                <%
                                    }
                                %>
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td colspan="2"><a href="user_register.html">还没账号？去注册>>>></a></td>
                        </tr>
                    </table>
            </table>
            <script type="text/javascript">

                $.extend($.fn.validatebox.defaults.rules, {

                    loginname: {

                        validator: function (value, param) {

//                    return /^[a-z]+[0-9]+$/gi.test(value);

                            var loginname = value;

                            var name_check_1 = /[a-zA-Z]+/;//必须有字母

                            var name_check_2 = /[0-9]+/;//必须有数字

                            var name_check_3 = /^[a-zA-Z]{1}[a-zA-Z0-9_.]{5,19}$/;

                            var name_check = true;

                            var name_c = "用户名不能为空";


                            if (!name_check_1.test(loginname)) {

                                name_check = false;

                                name_c = name_c + "字母（不区分大小写）";

                            }

                            if (!name_check_2.test(loginname)) {

                                name_check = false;

                                name_c = name_c + "数字";

                            }

                            if (!name_check_3.test(loginname)) {

                                name_check = false;

                                name_c = "字母开头，不能出现除“_”“.”以外的特殊字符"

                            }

                            return name_check;

                        },

                        message: '用户名是6-20位字母和数字的组合（字母开头，不包含除“_”“.”以外的特殊字符）'

                    },

                    password: {

                        validator: function (value, param) {

                            return /^[a-z0-9_.]{6,20}$/gi.test(value);

                        },

                        message: '密码是6-20的字符组合（不包含除“_”“.”以外的特殊字符）'

                    }

                });

                function reloadcode() {
                    document.getElementById("codeimage").src = "User/ValidateCode?t=" + new Date();
                }
            </script>
        </div>
    </div>
</form>
</body>
</html>
